package com.jp.knowledge.my.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.LinearLayout;

import com.jp.knowledge.R;
import com.jp.knowledge.comm.JpApplication;
import com.jp.knowledge.model.UserData;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.my.model.ActiveDataModel;

import org.xutils.common.util.DensityUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author gzejia 978862664@qq.com
 */
public class MyDataAdapter extends RecycleVAdapter<ActiveDataModel> {
//    List<String> values = new ArrayList<>();
    public MyDataAdapter(Context context, @NonNull List<ActiveDataModel> list) {
        super(context, list);
//        UserData userData  = ((JpApplication)context.getApplicationContext()).getUserData();
//        if(userData!=null){
//            values.add(String.valueOf(userData.getMessageNum()));
//            values.add(String.valueOf(userData.getFollowNum()));
//            values.add(String.valueOf(userData.getOrderNum()));
//            values.add(String.valueOf(userData.getTotalAmount()/100.00));
//            values.add(String.valueOf(userData.getIntegralNum()));
//
//        }else{
//            values.add("0");
//            values.add("0");
//            values.add("0");
//            values.add("0.00");
//            values.add("0");
//        }
    }

    @Override
    public int getLayoutId(int viewType) {
//        return R.layout.item_my_data;
        return R.layout.item_my_more;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        holder.getConvertView().setLayoutParams(
                new LinearLayout.LayoutParams(DensityUtil.getScreenWidth()/3, LinearLayout.LayoutParams.WRAP_CONTENT));
        ActiveDataModel model = getData(position);
//        holder.setTextView(R.id.my_item_tv_number,model.value);
//        holder.setTextView(R.id.my_item_tv_unit, model.mUnit);
//        holder.setTextView(R.id.my_item_tv_type, model.mName);
        holder.setTextView(R.id.my_item_tv_value, model.mName);
        holder.get(R.id.tip_text).setVisibility(View.GONE);
        holder.getImageView(R.id.my_item_iv_icon).setImageResource(model.mIcon);
    }
}
